/*
 * State_D.h
 *
 *  Created on: 15.05.2011
 *      Author: Tim
 */

#ifndef State_D_H_
#define State_D_H_

//Bibliotheken
#include <pthread.h>
#include <stdio.h>
#include <sys/neutrino.h>
#include <hw/inout.h>
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <errno.h>

#include "HAL.h"
#include "Timer.h"
#include "OutBefehle.h"
#include "AmpelController.h"
#include "SensorStates.h"
#include "Communication.h"

#define D_TIMER_RUTSCHE_s 0
#define D_TIMER_RUTSCHE_ns 500000000
#define D_TIMER_VALID_s 1
#define D_TIMER_VALID_ns 700000000		//0,5 sek
#define D_TIMER_PUCK_s 5
#define D_TIMER_PUCK_ns 500000000

extern bool bandFrei;

class State_D {
public:
	State_D();
	virtual ~State_D();

	virtual void in_einlauf(void);
	virtual void in_hoehenmessung(void);
	virtual void in_auslauf(void);
	virtual void nicht_in_weiche(void);
	virtual void start_gedrueckt(void);
	virtual void reset_gedrueckt(void);
	virtual void stop_gedrueckt(void);
	virtual void in_weiche(void);
	virtual void setComPointer(Communication * com);
	virtual void send(void);
	virtual void in_rutsche(void);
	virtual void nicht_in_rutsche(void);
	virtual void fehler_rutsche_voll(void);


	virtual void timer_fehler(void);
	virtual void valid_delete(void);
	virtual void timer_unpause(void);
	virtual void timer_pause(void);
	virtual void valid_abgelaufen(void);
	virtual void timer_abgelaufen(void);
	virtual void getTimer(void);

	void getHAL(void);

	HAL * hal;
	AmpelController * ampelCon;
	Communication * com;
	Timer * timerRutsche;
	Timer * timerD;
	Timer * timerValidAuslauf;
	long long timerValidAuslauf_rest;
	long long timer_rest;

	bool validAuslauf;

	int zustand;
	int hoehe;
	int fehlercode;

};

#endif /* State_D_H_ */



